﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using UberChess.Structure.Pieces;

namespace UberChess.StateTools
{
   public class StateTools
   {

      public static List<Vector2> GetKingPosition(State state, Side color)
      {
         return FindPiecePositions(state, color, typeof(King), 1);
      }

      public static List<Vector2> GetQueenPosition(State state, Side color)
      {
         return FindPiecePositions(state, color, typeof(Queen), 1);
      }

      public static List<Vector2> GetBishopsPosition(State state, Side color)
      {
         return FindPiecePositions(state, color, typeof(Bishop), 2);
      }

      public static List<Vector2> GetRooksPosition(State state, Side color)
      {
         return FindPiecePositions(state, color, typeof(Rook), 2);
      }

      public static List<Vector2> GetKnightsPosition(State state, Side color)
      {
         return FindPiecePositions(state, color, typeof(Knight), 2);
      }

      public static List<Vector2> GetPawnsPosition(State state, Side color)
      {
         return FindPiecePositions(state, color, typeof(Pawn), 8);
      }


      private static List<Vector2> FindPiecePositions(State state, Side color, Type type, int maxCount)
      {
         List<Vector2> positions = new List<Vector2>();


         positions = (from piece in state.GetPieces()
                      where piece.GetType() == type && piece.GetSide() == color
                      select piece.CurrentPosition).ToList();

         return positions;


      }
   }
}
